﻿using System;
using System.Collections;
using System.Linq;
using System.Windows;
using System.Windows.Media;

namespace Charts.Converters
{
	/// <summary> Used to palce value labels verticaly</summary>
	public class YValueLabelConverter : MultiValueConverterBase<YValueLabelConverter>
	{
		public override object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			try {
				
				double h = (double)values[0];
				double ch = (double)values[1];
				
				double max = (double)values[2];
				double min = (double)values[3];
				
				double v = (double)values[4];
				
				double d = System.Convert.ToDouble(parameter);
	
				return ch * (max - v) / (max - min) - d - h;
				
			} catch (Exception) { return DependencyProperty.UnsetValue; }
		}
	}
}
